package com.ruoyi.swimming.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.swimming.domian.MallOrder;
import com.ruoyi.swimming.domian.MallOrderDetails;
import com.ruoyi.swimming.mapper.MallOrderDetailsMapper;
import com.ruoyi.swimming.mapper.MallOrderMapper;
import com.ruoyi.swimming.service.IMallOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 商城订单Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@Service
public class MallOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrder> implements IMallOrderService
{
    @Autowired
    private MallOrderMapper mallOrderMapper;

    /**
     * 查询商城订单
     * 
     * @param id 商城订单ID
     * @return 商城订单
     */
    @Override
    public MallOrder selectMallOrderById(Long id)
    {
        return mallOrderMapper.selectMallOrderById(id);
    }

    /**
     * 查询商城订单列表
     * 
     * @param mallOrder 商城订单
     * @return 商城订单
     */
    @Override
    public List<MallOrder> selectMallOrderList(MallOrder mallOrder)
    {
        return mallOrderMapper.selectMallOrderList(mallOrder);
    }

    /**
     * 新增商城订单
     * 
     * @param mallOrder 商城订单
     * @return 结果
     */
    @Override
    public int insertMallOrder(MallOrder mallOrder)
    {
        mallOrder.setCreateTime(DateUtils.getNowDate());
        return mallOrderMapper.insert(mallOrder);
    }

    /**
     * 修改商城订单
     * 
     * @param mallOrder 商城订单
     * @return 结果
     */
    @Override
    public int updateMallOrder(MallOrder mallOrder)
    {
        mallOrder.setUpdateTime(DateUtils.getNowDate());
        return mallOrderMapper.updateById(mallOrder);
    }

    /**
     * 批量删除商城订单
     * 
     * @param ids 需要删除的商城订单ID
     * @return 结果
     */
    @Override
    public int deleteMallOrderByIds(Long[] ids)
    {
        return mallOrderMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除商城订单信息
     * 
     * @param id 商城订单ID
     * @return 结果
     */
    @Override
    public int deleteMallOrderById(Long id)
    {
        return mallOrderMapper.deleteById(id);
    }
}
